*******************************************************************************
******************************  TABLE A9  *************************************
*******  Individual and Group Performance on Team-building Task,  *************
****************  Final Project, and Course Grades  ***************************
*******************************************************************************


clear all
set more off

//cd "C:/Users/ganth/Dropbox/StrengthInNumbersReplicationPackage/replicable/table_a9"

*******************************************************************************

*Combined Sample
use "table_a9_dataset_1.dta", clear 
eststo clear
*Column 1: Differences in group lab performance from implied aggregate of individual responses across conditions for combined sample (averaged across two labs 1 and 2 and Study 2 lab 1)
eststo: reg gavg_total_ravg maleMajority, robust
estadd ysumm
*Column 2: Differences in group lab performance across conditions for combined sample (averaged across two labs 1 and 2 and Study 2 lab 1)
eststo: reg g_total_ravg maleMajority, robust
estadd ysumm


use "table_a9_dataset_2.dta", clear
eststo: reg TotalIndividualScore_avg maleMajority  , cluster(group_id)
estadd ysumm
collapse TotalGroupScore_avg maleMajority, by(group_id)
count
eststo: reg TotalGroupScore_avg  maleMajority, robust
estadd ysumm


**Grades analysis
**Individual-level, Study 1
use "table_a9_dataset_3.dta", clear
reg gpa_core_fall maleMajority, cluster(group_id_fall)
reg gpa_core_total maleMajority, cluster(group_id_fall)


**Group-level, Study 1
collapse gpa_core_fall gpa_core_total maleMajority, by(group_id_fall)
eststo: reg gpa_core_fall maleMajority, robust
estadd ysumm


**Individual-level, Study 2
use "table_a9_dataset_4.dta", clear
reg gpa_amher maleMajority, cluster(group_id)
collapse gpa_amher maleMajority, by(group_id)
eststo: reg gpa_amher maleMajority, robust
estadd ysumm

esttab _all using "table_a9.tex", style(tex) ///
 stats(N ymean ysd, fmt( %9.0g %9.2f  %9.2f %9.2f) ///
labels("/$N$" "Mean of outcome" "St. dev. of outcome")) label replace ///
keep( maleMajority) ///
star( * .1 ** .05 *** .01) b(%9.3f) se(%9.3f) nogaps  ///
mtitles("/makecell{(1)//Individual //Task Errors//Studies 1 + 2}" "/makecell{(2)//Group //Task Errors//Studies 1+2}" "/makecell{(3)//Individual //Project Score //Study 2}" "/makecell{(4)//Group //Project Score //Study 2}" "/makecell{(5)//Group //Average Grade //Study 1}" "/makecell{(6)//Group //Average Grade //Study 2}" ) ///
nonotes nonum addnotes("/begin{minipage}{.6/linewidth} /footnotesize /smallskip /textbf{Note:} Significance levels are indicated by $*$ $<.1$, ** $<.05$,  *** $<.01$.  Heteroskedasticity-robust standard errors are reported in parenthees. In individual-level analysis, standard errors are clustered by group. \end{minipage}" )
